//////////////////////////////////////////
// Make Table S8
//////////////////////////////////////////

gl path "~/Dropbox/CovidTurnout/replication"


**** first three columns of table will be for TX
use "$path/original_data/analysis_file.dta", clear
keep if year==2020

keep if voted==100
replace dem = 0 if dem==.

*collapse dem [fw=obs], by(year age)

gen rv = age-65
gen treat = age >= 65
gen rv_treat = rv*treat
gen rv2 = rv^2
gen rv_treat2 = rv2*treat
gen rv3 = rv^3
gen rv_treat3 = rv3*treat



reg dem treat if inlist(age, 64, 65) [fw=obs], r
local b1 = _b[treat]
local se1 = _se[treat]
local n1 = e(N)

reg dem treat rv* if age >= 55 & age < 75 [fw=obs], r
local b2 = _b[treat]
local se2 = _se[treat]
local n2 = e(N)

reg dem treat rv* if age >= 45 & age < 85 [fw=obs], r
local b3 = _b[treat]
local se3 = _se[treat]
local n3 = e(N)


*** second three columns are for IN
use "$path/original_data/analysis_file_indiana.dta", clear
keep if year==2020

keep if voted==100
replace dem = 0 if dem==.

gen rv = age-65
gen treat = age >= 65
gen rv_treat = rv*treat
gen rv2 = rv^2
gen rv_treat2 = rv2*treat
gen rv3 = rv^3
gen rv_treat3 = rv3*treat

reg dem treat if inlist(age, 64, 65) [fw=obs], r
local b4 = _b[treat]
local se4 = _se[treat]
local n4 = e(N)

reg dem treat rv* if age >= 55 & age < 75 [fw=obs], r
local b5 = _b[treat]
local se5 = _se[treat]
local n5 = e(N)

reg dem treat rv* if age >= 45 & age < 85 [fw=obs], r
local b6 = _b[treat]
local se6 = _se[treat]
local n6 = e(N)


quietly {
	cap log close
	set linesize 255

	log using "$path/output/party_table_IN_TX.tex", text replace
	
	noisily dis "\begin{table}[t]"
	noisily dis "\centering"
	noisily dis "\caption{\textbf{Effect of No-Excuse Absentee Voting on Party Turnout in 2020.}\label{tab:party_in_tx}}"
	noisily dis "\begin{tabular}{lccc|ccc}"
	noisily dis "\toprule \toprule"
	noisily dis "& \multicolumn{3}{c}{\underline{Texas}} & \multicolumn{3}{c}{\underline{Indiana}} \\[1mm]"
	noisily dis "& \multicolumn{3}{c}{Dem \% of Turnout [0-100]} & \multicolumn{3}{c}{Dem \% of Turnout [0-100]}\\[1mm]"
	noisily dis "& (1) & (2) & (3) & (4) & (5) & (6) \\"
	noisily dis "\midrule"
	noisily dis "No-Excuse (Age $\geq$ 65) & " %4.2f `b1' " & " %4.2f `b2' " & " %4.2f `b3' " & " %4.2f `b4' " & " %4.2f `b5' " & " %4.2f `b6' "\\"
	noisily dis " & (" %4.2f `se1' ") & (" %4.2f `se2' ") & (" %4.2f `se3' ") & (" %4.2f `se4' ") & (" %4.2f `se5' ") & (" %4.2f `se6' ") \\[2mm]"
	noisily dis "\# Obs & " %8.0fc `n1' " & " %9.0fc `n2' " & " %9.0fc `n3' " & " %8.0fc `n4' " & " %9.0fc `n5' " & " %9.0fc `n6' "\\[1mm]"
	noisily dis "Ages Included & 64-65 & 55-75 & 45-85 & 64-65 & 55-75 & 45-85  \\"
	noisily dis "Age Specification & -- & Cubic & Cubic & -- & Cubic & Cubic \\"
	noisily dis "\bottomrule \bottomrule"
	noisily dis "\multicolumn{7}{p{.9\textwidth}}{\footnotesize Robust standard errors in parentheses."
	noisily dis "Columns 1 and 4 present the simple difference in means for voters aged 65 vs. 64."
	noisily dis "Columns 2-3 and 5-6 present estimates that include a broader range of ages and "
	noisily dis "adjust for age trends using cubic specifications of age estimated separately on either side"
	noisily dis " of the discontinuity.}"
	noisily dis "\end{tabular}"
	noisily dis "\end{table}"
	
	log off
	
}
	








